using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using TMS.Application.Common.Interface;
using TMS.Domain.Entity;

namespace TMS.Api.Controllers
{
    [ApiController]
    [Route("[controller]")]
    public class TeacherController:ControllerBase
    {
        private readonly IRepository<Teachers> _Teachers;//教师账号表
        private readonly IFileUploadService _fileUploadService;//获取头像(暂且)

        public TeacherController(IRepository<Teachers> Teachers,IFileUploadService fileUploadService)
        {
            _Teachers=Teachers;
            _fileUploadService=fileUploadService;
        }
        [HttpGet("/GetTeaInfo/{TeacherId}")]
        public async Task<object> GetTeaInfo(string TeacherId)
        {
            var t = _Teachers.Table.ToList();
            var TeaInfo = t.Where(x => x.TeacherId == TeacherId).FirstOrDefault();
            if (TeaInfo == null)
            {
                return new
                {
                    code = 200,
                    msg = "查无此教工",
                    data = ""
                };
            }
            else
            {
                var obj = new
                {
                    TeaInfo.TeacherId,
                    TeaInfo.TeacherName,
                    TeacherPhone=TeaInfo.PhoneNumber,
                    TeaInfo.ChattingNumber

                };
                return new
                {
                    code=200,
                    msg="获取成功！！",
                    data=obj
                };

            }

        }

    }
}